package calculateTax;

public class Solution {
    public double calculateTax(int[][] brackets, int income) {
        double ans = 0;
        int last = 0;
        for (int i = 0; i < brackets.length; i++) {
            if(brackets[i][0]<=income) {
                ans+=(brackets[i][0]-last)*brackets[i][1]*0.01;
                last = brackets[i][0];
            }else {
                ans+=(brackets[i][0] - income)*brackets[i][1]*0.01;
                break;
            }
        }
        return ans;
    }
}
